package com.angel.interfaces;

import com.angel.application.commandgateways.AngelUserCommandService;
import com.angel.application.dto.AngelUserInfoDTO;
import com.angel.domain.angeluser.valueobjects.AngelUserId;
import com.angel.infrastructure.common.ResultBody;
import com.angel.interfaces.converter.AngelUserInfoDTOConverter;
import com.angel.interfaces.vo.AngelUserInfoVO;
import org.springframework.web.bind.annotation.*;


/*
 * 更新关注微信公众号： 为了offer
 * @author parkin
 * @description
 * @date 2021/11/13
 */
@RestController
@RequestMapping("/angel_user_info")
public class AngelUserInfoController {


    private final AngelUserCommandService angelUserCommandService;

    public AngelUserInfoController(AngelUserCommandService angelUserCommandService) {
        this.angelUserCommandService = angelUserCommandService;
    }

    /**
     * 查询用户信息
     * @return 返回用户详情VO
     */
    @GetMapping("/detail/{angelUserId}")
    public ResultBody<AngelUserInfoVO> detail(@PathVariable Long angelUserId) {
        AngelUserInfoDTO angelUserInfoDTO = angelUserCommandService.get(
                AngelUserId.toAngelUserId(angelUserId)
        );
        return ResultBody.success(
                AngelUserInfoDTOConverter.INSTANCE.toAngelUserInfoVO(angelUserInfoDTO)
        );
    }
}
